<?php
/**
 * Created by PhpStorm.
 * User: deng
 * Date: 2017/2/10
 * Time: 16:54
 */
class BaseService{

    protected $errorNo;
    protected $errorMsg;
    protected $validator;

    static private $instanceContainer = [];

    public function __construct()
    {
        $this->validator = new GUMP();
    }

    /**
     * 获取调用服务的单例实例
     * @return static
     */
    static public function getInstance(){
        $call_class_name = get_called_class();
        if (isset(self::$instanceContainer[$call_class_name]))
            return self::$instanceContainer[$call_class_name];
        self::$instanceContainer[$call_class_name] = new $call_class_name;
        return self::$instanceContainer[$call_class_name];
    }

    public function __destruct()
    {
        AC::$errorNo = $this->errorNo;
        AC::$errorMsg = $this->errorMsg;
    }

}